package com.sc.admin.common.util;

import cn.hutool.crypto.digest.MD5;

/**
 *@Author shen chen
 *@Date 2024-05-07
 */
public class PasswordEncoderUtils {

    private static final String salt = "Adjh8*>}.=-+_W123#@4xdf6.";

    public static String encode(String rawPassword) {
        // 加盐加密 md5
        return MD5.create().setSalt(salt.getBytes()).digestHex(rawPassword);
    }

    public static boolean matches(String oldPassword, String password) {
        return ObjUtils.equals(encode(oldPassword), password);
    }

    public static void main(String[] args) {
        String encode = encode("123456");
        System.out.println("encode = " + encode);
    }
}
